package com.model
{
	import com.model.valueObjects.VOProductImage;
	import com.model.valueObjects.VoEnquiryHeader;
	import com.view.Searching.com.ClientTrIn;
	import com.view.Searching.com.ClientTrOut;
	import com.view.Searching.com.InorderLinksPopup;
	import com.view.Searching.com.OnHandLinksPopup;
	import com.view.Searching.com.OnSaleLinksPopup;
	import com.view.Searching.com.SoldLinksPopup;
	
	import flash.utils.ByteArray;
	
	import mx.collections.ArrayCollection;
	import mx.messaging.channels.StreamingAMFChannel;
	import mx.rpc.CallResponder;
	
	
	//import valueObjects.VOProduct;
	
	public class Model
	{
		[Bindable]
		public var loadingImageByteArr:ByteArray;
		
		[Bindable]
		public var busyCurrsorOn:Boolean;
		
		[Bindable]
		public var mainBuingClicked:Boolean;
		
		[Bindable]
		public var mainSellingClicked:Boolean;
		
		[Bindable]
		public var mainSearchClicked:Boolean;
		
		[Bindable]
		public var mainReportClicked:Boolean;
		
		[Bindable]
		public var editButtonVisible:Boolean;
		
		[Bindable]
		public var delButtonVisible:Boolean;
		
		//Main Stack
		[Bindable]
		public var currentWindowIndex:Number;
		
		//User Rights		
		[Bindable]
		public var userType:Number;		
		
		// Admin Table index
		[Bindable]
		public var currentAdminTableIndex:Number;
		
		// Buying Form index
		[Bindable]
		public var currentBuyFormsIndex:Number;
		
		// Buying Table index
		[Bindable]
		public var currentBuyTableIndex:Number;
		
		// Selling Form index
		[Bindable]
		public var currentSellFormsIndex:Number;
		
		// Selling Table index
		[Bindable]
		public var currentSellTableIndex:Number;
		
		// List of products
		[Bindable]
		public var saveCloseBtn:Boolean;
		
		// List of products
		[Bindable]
		public var products:ArrayCollection;
		
		[Bindable]
		public var currentScreen:Number;
				
		[Bindable]
		public var currentList:ArrayCollection;
		
		//User Privillages
		[Bindable]
		public var userPrivillageDetails:ArrayCollection;
		
		//Current User Privillages
		[Bindable]
		public var currentUserSetting:ArrayCollection;
		
		//User Master
		[Bindable]
		public var userMasterDetails:ArrayCollection;
		
		[Bindable]
		public var userImage:ByteArray;
		
		[Bindable]
		public var supplierListDetails:ArrayCollection;
		
		[Bindable]
		public var customerListDetails:ArrayCollection;
		
		[Bindable]
		public var currentForm:Number;
		[Bindable]
		public var currentFormState:String;
		
		[Bindable]
		public var visibleTableColumns:Array;
		
		[Bindable]
		public var headerTableColumns:ArrayCollection;
		
		//Company Master
		[Bindable]
		public var companyMasterList:ArrayCollection;
		
		[Bindable]
		public var companyList:ArrayCollection;
		
		//Product Master
		
		[Bindable]
		public var productImage:ByteArray;
		
		[Bindable]
		public var productMasterList:ArrayCollection;
		
		[Bindable]
		public var proNameArr:ArrayCollection;
		
		[Bindable]
		public var partNoArr:ArrayCollection;
		
		[Bindable]
		public var stampNoArr:ArrayCollection;
		
		[Bindable]
		public var productName:ArrayCollection;
		
		[Bindable]
		public var productList:ArrayCollection;
		
		[Bindable]
		public var productListWithPrice:ArrayCollection;
		
		//Combination Master
		[Bindable]
		public var countryCurrencyList:ArrayCollection;
		
		//client Master
		[Bindable]
		public var clientMasterList:ArrayCollection;
		
		//Currency Master
		[Bindable]
		public var currencyMasterList:ArrayCollection;
		
		//Currency Master
		[Bindable]
		public var currencyDetailList:ArrayCollection;
		
		[Bindable]
		public var currencyDetSerialList:ArrayCollection;
		
		//branch Master
		[Bindable]
		public var branchMasterList:ArrayCollection=new ArrayCollection();
		
		[Bindable]
		public var branchList:ArrayCollection=new ArrayCollection();
		
		[Bindable]
		public var branchMasterComboList:ArrayCollection=new ArrayCollection();
		
		//Warehouse Master
		[Bindable]
		public var warehouseMasterList:ArrayCollection;
		
		//Country Master
		[Bindable]
		public var countryMasterList:ArrayCollection;
		
		//State Master		
		[Bindable]
		public var stateMasterList:ArrayCollection;
		
		//Category Master
		[Bindable]
		public var categoryMasterList:ArrayCollection;
		
		//Markup Master
		[Bindable]
		public var markupMasterList:ArrayCollection;
		
		[Bindable]
		public var getMarginalMarkup:ArrayCollection;
		
		[Bindable]
		public var getNetMarkup:ArrayCollection;	
		
		//**************Search **********///
		
		[Bindable]
		public var currentColumnsList:ArrayCollection;
		
		//**************Search **********///
		
		
		
		//**************STOCK **********///
		
		[Bindable]
		public var stockList:ArrayCollection;
		
		//**************STOCK **********///
		
		
		
		//**************Buying **********///
		//Enquiry List
		[Bindable]
		public var enqCode:String;
		
		[Bindable]
		public var enquiryList:ArrayCollection;
		
		[Bindable]
		public var enquiryListPopup:ArrayCollection;
		
		[Bindable]
		public var enquiryListPopupHeader:ArrayCollection;
		
		[Bindable]
		public var enquiryDetail:VoEnquiryHeader;
		
		[Bindable]
		public var enquiryHeaderDetails:ArrayCollection;
		
		[Bindable]
		public var enquirySupplierList:ArrayCollection;
		
		//Purchase Order List
		[Bindable]
		public var poCode:String;
		
		[Bindable]
		public var grCode:String;
		
		
		[Bindable]
		public var grPOList:ArrayCollection;
		
		[Bindable]
		public var poStackIndex:Number;
		
		[Bindable]
		public var poFrmSelectedProducts:ArrayCollection;
		
		[Bindable]
		public var poHeaderList:ArrayCollection;
		
		[Bindable]
		public var proItemForGr:ArrayCollection;
		[Bindable]
		public var poItemForGr:ArrayCollection;
		
		
		[Bindable]
		public var poItemOtherScForGr:ArrayCollection;

		
		//Purchase Order Amendment List
		[Bindable]
		public var poAmendmentHeaderList:ArrayCollection;
		
		//GoodsReceived List
		[Bindable]
		public var goodsReceivedList:ArrayCollection;
		
	//	[Bindable]
		//public var po_gst:Number;
		
		[Bindable]
		public var grHeaderList:ArrayCollection;
		
		//Transaction Note Buying
		[Bindable]
		public var buyingTransactionNote:ArrayCollection;
		
		[Bindable]
		public var buyingEditOrView:Boolean;
		
		//**************Buying **********///
		
		//**************Selling **********///
		[Bindable]
		public var sellingEditOrView:Boolean;
		
		//Quotation List
		
		[Bindable]
		public var qutCode:String;
		[Bindable]
		public var quotationList:ArrayCollection;
		
		[Bindable]
		public var quotationListPopup:ArrayCollection;
		
		[Bindable]
		public var quotationSupplierList:ArrayCollection;
		
		//SalesConformation List
		[Bindable]
		public var scStackIndex:Number;
		
		[Bindable]
		public var scHeaderList:ArrayCollection;
		
		[Bindable]
		public var scFooterList:ArrayCollection;
		
		[Bindable]
		public var salesConformationList:ArrayCollection;
		
		[Bindable]
		public var scItemsForDo:ArrayCollection;
		
		[Bindable]
		public var poFreeAloocation:ArrayCollection;
		
		[Bindable]
		public var scUnMappedIndent:ArrayCollection;
		
		//Delivery Order List
		[Bindable]
		public var deliveryOrderList:ArrayCollection;
		
		[Bindable]
		public var doItemForInvoice:ArrayCollection;
		
		//Invoice List
		[Bindable]
		public var invoiceList:ArrayCollection;
		
		[Bindable]
		public var invoiceHeaderList:ArrayCollection;
		
		//Sales Brochure List
		
		[Bindable]
		public var salesBrochureList:ArrayCollection;
		
		[Bindable]
		public var slowMovingStockList:ArrayCollection;
		
		//Transaction Note Selling
		[Bindable]
		public var sellingTransactionNote:ArrayCollection;
		
		//**************Selling **********///
		
		//**************Search **********///
		
		// Searching Form index
		[Bindable]
		public var currentSearchFormsIndex:Number;
		
		[Bindable]
		public var currentSearchTableIndex:Number;
		
		/***************Product Search ***********/
		
		//Produt List
		[Bindable]
		public var productListSearch:ArrayCollection;
		
		//On hand 		
		[Bindable]
		public var proOnHandLinks:ArrayCollection;
		
		//On Sale 		
		[Bindable]
		public var proOnSaleLinks:ArrayCollection;
		
		//In Order 		
		[Bindable]
		public var proInOrderLinks:ArrayCollection;
		
		//Sold 		
		[Bindable]
		public var proSoldLinks:ArrayCollection;
		
		/***************Product Search End***********/
		
		
		/***************PO Search***********/
		
		[Bindable]
		public var poSearchHeader:ArrayCollection;		
		
		[Bindable]
		public var poSearchDetail:ArrayCollection;
		
		[Bindable]
		public var poSearchGrLinks:ArrayCollection;		
		
		
		/***************PO Search End***********/
		
		
		/***************SC Search***********/
		
		[Bindable]
		public var scSearchHeader:ArrayCollection;		
		
		[Bindable]
		public var scSearchDetail:ArrayCollection;	
		
		[Bindable]
		public var scSearchDoLinks:ArrayCollection;	
		
		/***************SC Search End***********/
		
				
		/***************Client Search ***********/
		
		//Client TR IN
		[Bindable]
		public var trInLinks:ArrayCollection;
		
		//Client TR OUT
		[Bindable]
		public var trOutLinks:ArrayCollection;
		
		//Stack Index
		[Bindable]
		public var clientSearchIndex:Number;
		
		/***************Client Search End***********/
		
		
		//**************Search **********///
		
		//**************Reports**********///
		
		
		
		//**************Reports**********///
		
		[Bindable]
		public var currentMenu:String;
		
		[Bindable]
		public var poDraftStatus:Boolean;
		
		[Bindable]
		public var poStatus:String;
		
		[Bindable]
		public var scStatus:String;
		
		public function Model()
		{
		}
		
		public function getItemByIndex( usid:Number, coll:ArrayCollection,objProperty:String):Number{
			var o:Object;
			for ( var i:Number = 0; i<coll.length; i++){
				o = coll.getItemAt(i);
				var index:Number =Number(o[objProperty]);
				if(index  == usid) return i;
			}
			return -1;
		}
		
		public function getCurrencyByFk( usid:Number, coll:ArrayCollection):String{
			var o:Object;
			for ( var i:Number = 0; i<coll.length; i++){
				o = coll.getItemAt(i);
				var index:Number =o.serialnumber;
				if(index  == usid) return o.currency_name;
			}
			return "";
		}
		
		public function getIndexByName( usid:String, coll:ArrayCollection,objProperty:String):Number{
			var o:Object;
			for ( var i:Number = 0; i<coll.length; i++){
				o = coll.getItemAt(i);
			var name:String = String(o[objProperty]);
			if(name == usid) return i;
			}
			return -1;
		}
		
	}
}